package com.imist.nettybasic4.client.console;

import com.imist.nettybasic4.protocol.request.LoginRequestPacket;
import com.imist.nettybasic4.protocol.request.LogoutRequestPacket;
import io.netty.channel.Channel;

import java.util.Scanner;

public class LoginConsoleCommand implements ConsoleCommand {
    @Override
    public void exec(Scanner scanner, Channel channel) {
        LoginRequestPacket loginRequestPacket = new LoginRequestPacket();
        System.out.println("输入用户名登陆:");
        loginRequestPacket.setUsername(scanner.nextLine());
        loginRequestPacket.setPassword("123456");
        channel.writeAndFlush(loginRequestPacket);
        waitForLoginResponse();
    }
    private static void waitForLoginResponse() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ignored) {
        }
    }
}
